﻿using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

// Token: 0x02000021 RID: 33
public class PauseManager : MonoBehaviour
{
	// Token: 0x0600008D RID: 141 RVA: 0x0000E820 File Offset: 0x0000CA20
	private void Start()
	{
		PauseManager.main = this;
		Time.timeScale = 1f;
		if (!PlayerPrefs.HasKey("dmgNumbers"))
		{
			PlayerPrefs.SetInt("dmgNumbers", 1);
		}
		if (SceneManager.GetActiveScene().name == "SampleScene")
		{
			this.goToText.text = "Go to tutorial";
		}
		else
		{
			this.goToText.text = "Go to arena";
		}
		this.dmgToggle.isOn = (PlayerPrefs.GetInt("dmgNumbers") == 1);
		GameManager.main.doDmgNum = (PlayerPrefs.GetInt("dmgNumbers") == 1);
		if (PlayerPrefs.GetInt("gameComplete") == 1)
		{
			this.originSelectButton.interactable = true;
		}
		this.UpdateAchievements();
	}

	// Token: 0x0600008E RID: 142 RVA: 0x0000E8E0 File Offset: 0x0000CAE0
	public void UpdateAchievements()
	{
		for (int i = 0; i < this.achievements.Count; i++)
		{
			if (PlayerPrefs.GetInt("achievement" + i.ToString()) > 0)
			{
				this.achievements[i].color = Color.green;
			}
			else
			{
				this.achievements[i].color = Color.gray;
			}
		}
	}

	// Token: 0x0600008F RID: 143 RVA: 0x0000E94C File Offset: 0x0000CB4C
	public void TryUnlockAchievement(int index)
	{
		if (PlayerPrefs.GetInt("achievement" + index.ToString()) < 1)
		{
			PlayerPrefs.SetInt("achievement" + index.ToString(), 1);
			this.achGetImage.color = Color.white;
			this.achGetText.color = Color.white;
			this.UpdateAchievements();
		}
	}

	// Token: 0x06000090 RID: 144 RVA: 0x0000E9AF File Offset: 0x0000CBAF
	public void SetAchievementText(string text, float yPos)
	{
		this.achDescription.rectTransform.anchoredPosition = new Vector2(this.achDescription.rectTransform.anchoredPosition.x, yPos);
		this.achDescription.text = text;
	}

	// Token: 0x06000091 RID: 145 RVA: 0x0000E9E8 File Offset: 0x0000CBE8
	private void Update()
	{
		if (this.paused)
		{
			this.pauseMenu.anchoredPosition = Vector2.Lerp(this.pauseMenu.anchoredPosition, new Vector2(this.desiredMenuX, 0f), Time.unscaledDeltaTime * 5f);
			this.achievementOpener.anchoredPosition = Vector2.Lerp(this.achievementOpener.anchoredPosition, new Vector2(0f, this.achievementOpener.anchoredPosition.y), Time.unscaledDeltaTime * 5f);
		}
		else
		{
			this.pauseMenu.anchoredPosition = Vector2.Lerp(this.pauseMenu.anchoredPosition, new Vector2(-this.desiredMenuX * 4f, 0f), Time.unscaledDeltaTime * 5f);
			this.achievementOpener.anchoredPosition = Vector2.Lerp(this.achievementOpener.anchoredPosition, new Vector2(400f, this.achievementOpener.anchoredPosition.y), Time.unscaledDeltaTime * 5f);
		}
		this.achMenu.anchoredPosition = new Vector2(this.achievementOpener.anchoredPosition.x, 0f);
		if (Input.GetKeyDown(KeyCode.Escape))
		{
			if (this.paused)
			{
				this.UnPause();
			}
			else
			{
				this.Pause();
			}
		}
		if (this.paused)
		{
			if (MusicManager.main)
			{
				this.musicText.text = Mathf.RoundToInt(MusicManager.main.volume * 100f).ToString() + "%";
			}
			else
			{
				this.musicText.text = "Nope.";
			}
			this.lowHptext.text = Mathf.RoundToInt(BloodDamageUI.main.healthVolMult * 100f).ToString() + "%";
			this.masterText.text = Mathf.RoundToInt(AudioListener.volume * 100f).ToString() + "%";
		}
		if (this.achGetImage.color.a > 0f)
		{
			this.achGetImage.color = new Color(1f, 1f, 1f, this.achGetImage.color.a - Time.deltaTime * 0.25f);
			this.achGetText.color = new Color(1f, 1f, 1f, this.achGetText.color.a - Time.deltaTime * 0.25f);
		}
	}

	// Token: 0x06000092 RID: 146 RVA: 0x0000EC7D File Offset: 0x0000CE7D
	public void Suicide()
	{
		GameManager.main.playerBody.health = -1f;
		this.UnPause();
	}

	// Token: 0x06000093 RID: 147 RVA: 0x0000EC99 File Offset: 0x0000CE99
	public void ToggleDmgNum()
	{
		if (this.dmgToggle.isOn)
		{
			PlayerPrefs.SetInt("dmgNumbers", 1);
			GameManager.main.doDmgNum = true;
			return;
		}
		PlayerPrefs.SetInt("dmgNumbers", 0);
		GameManager.main.doDmgNum = false;
	}

	// Token: 0x06000094 RID: 148 RVA: 0x0000ECD5 File Offset: 0x0000CED5
	public void OriginSelect()
	{
		GameManager.main.sceneLoadTarget = "OriginSelect";
		GameManager.main.fadingOut = true;
		base.GetComponent<Canvas>().sortingOrder = 0;
	}

	// Token: 0x06000095 RID: 149 RVA: 0x0000ED00 File Offset: 0x0000CF00
	public void Pause()
	{
		Time.timeScale = 0f;
		this.paused = true;
		this.runsText.text = "Completed runs: " + PlayerPrefs.GetInt("runsCompleted").ToString();
		this.achMenu.gameObject.SetActive(false);
		this.achDescription.text = "";
	}

	// Token: 0x06000096 RID: 150 RVA: 0x0000ED66 File Offset: 0x0000CF66
	public void UnPause()
	{
		Time.timeScale = 1f;
		this.paused = false;
		this.achDescription.text = "";
	}

	// Token: 0x06000097 RID: 151 RVA: 0x0000ED89 File Offset: 0x0000CF89
	public void QuitGame()
	{
		Application.Quit();
	}

	// Token: 0x06000098 RID: 152 RVA: 0x0000ED90 File Offset: 0x0000CF90
	public void Restart()
	{
		GameManager.main.fadingOut = true;
		base.GetComponent<Canvas>().sortingOrder = 0;
	}

	// Token: 0x06000099 RID: 153 RVA: 0x0000EDA9 File Offset: 0x0000CFA9
	public void GoToSandbox()
	{
		base.GetComponent<Canvas>().sortingOrder = 0;
		GameManager.main.sceneLoadTarget = "Sandbox";
		GameManager.main.fadingOut = true;
	}

	// Token: 0x0600009A RID: 154 RVA: 0x0000EDD4 File Offset: 0x0000CFD4
	public void SwitchMode()
	{
		base.GetComponent<Canvas>().sortingOrder = 0;
		if (SceneManager.GetActiveScene().name == "SampleScene")
		{
			GameManager.main.sceneLoadTarget = "RealTutorial";
			GameManager.main.fadingOut = true;
			return;
		}
		GameManager.main.sceneLoadTarget = "SampleScene";
		GameManager.main.fadingOut = true;
	}

	// Token: 0x0600009B RID: 155 RVA: 0x0000EE3B File Offset: 0x0000D03B
	public void ChangeLowHealthVol(float change)
	{
		BloodDamageUI.main.ChangeLowHealthVol(change);
	}

	// Token: 0x0600009C RID: 156 RVA: 0x0000EE48 File Offset: 0x0000D048
	public void ChangeMasterVol(float change)
	{
		GameManager.main.ChangeMasterVol(change);
	}

	// Token: 0x0600009D RID: 157 RVA: 0x0000EE55 File Offset: 0x0000D055
	public void ChangeVol(float change)
	{
		if (MusicManager.main)
		{
			MusicManager.main.volume += change;
			PlayerPrefs.SetFloat("musicVol", MusicManager.main.volume);
		}
	}

	// Token: 0x04000169 RID: 361
	[HideInInspector]
	public bool paused;

	// Token: 0x0400016A RID: 362
	public float desiredMenuX;

	// Token: 0x0400016B RID: 363
	public static PauseManager main;

	// Token: 0x0400016C RID: 364
	public RectTransform pauseMenu;

	// Token: 0x0400016D RID: 365
	public TextMeshProUGUI goToText;

	// Token: 0x0400016E RID: 366
	public TextMeshProUGUI musicText;

	// Token: 0x0400016F RID: 367
	public TextMeshProUGUI lowHptext;

	// Token: 0x04000170 RID: 368
	public TextMeshProUGUI masterText;

	// Token: 0x04000171 RID: 369
	public Button originSelectButton;

	// Token: 0x04000172 RID: 370
	public Toggle dmgToggle;

	// Token: 0x04000173 RID: 371
	public TextMeshProUGUI runsText;

	// Token: 0x04000174 RID: 372
	public RectTransform achievementOpener;

	// Token: 0x04000175 RID: 373
	public RectTransform achMenu;

	// Token: 0x04000176 RID: 374
	public List<TextMeshProUGUI> achievements;

	// Token: 0x04000177 RID: 375
	public Image achGetImage;

	// Token: 0x04000178 RID: 376
	public TextMeshProUGUI achGetText;

	// Token: 0x04000179 RID: 377
	public TextMeshProUGUI achDescription;
}
